import openpyxl

myBook=openpyxl.load_workbook('员工表.xlsx')
mySheet=myBook.active

myPieChart=openpyxl.chart.PieChart()
myPieChart.add_data(openpyxl.chart.Reference(mySheet,min_col=2,min_row=2,max_row=6))
myPieChart.set_categories(openpyxl.chart.Reference(mySheet,min_col=1,min_row=2,max_row=6))
myPieChart.style=26


mySlices=[openpyxl.chart.series.DataPoint(idx=1) for i in range(5)]
myPieChart.series[0].data_points=mySlices
mySlices[0].graphicalProperties.solidFill='FF0000'
mySlices[1].graphicalProperties.solidFill='00FF00'
mySlices[2].graphicalProperties.solidFill='0000FF'
mySlices[3].graphicalProperties.solidFill='000000'
mySlices[4].graphicalProperties.solidFill='00FFFF'

myPieChart.title='使用饼图展示华茂集团员工人数'
mySheet.add_chart(myPieChart,'C1')
myBook.save('结果表-员工表.xlsx')